<template>
	<div>
		<!-- 新增商品信息 -->
		<el-dialog title="新增商品" :visible.sync="AddGoodsVisible" style="height: 700px; border: 1px solid #eee">
			<el-form label-width="100px"  >
				<el-form label-width="100px">
					<el-form-item label="商品名">
						<el-input v-model="AddCommodityParam.goodsTableName" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="品牌">
						<el-select v-model="AddCommodityParam.goodsBrandsId" placeholder="请选择">
						<el-option v-for="item in brandInfos" :label="item.goodsBrandName"
								:value="item.goodsBrandId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="所属一类">
						<el-select v-model="AddCommodityParam.goodsGeneralId" @change="loadSmallInfo"
							placeholder="请选择一级类...">
						<el-option v-for="(item,index) in generalInfos" :label="item.goodsGeneralName"
								:value="item.goodsGeneralId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="所属二类">
						<el-select v-model="AddCommodityParam.goodsSmallId" @change="loadSmallerInfo"
							placeholder="请选择二级类...">
						<el-option v-for="(item,index) in smallInfos" :label="item.goodsSmallName"
								:value="item.goodsSmallId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label=" 所属三类">
						<el-select v-model="AddCommodityParam.goodsSmallerId" placeholder="请选择三级类..."
							@change="SmallerChange">
						<el-option v-for="item in smallerInfos" :label="item.goodsSmallerName"
								:value="item.goodsSmallerId"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="属性组" v-if="AddCommodityParam.goodsSmallerId!=null">


					<el-form-item v-for="(item,index) in listGoodProp">

							<!-- {{AddCommodityParam.GpropsList}} -->
							<!-- {{itemMin}} -->


							<el-radio-group v-model="AddCommodityParam.gpropsList1" v-if="item.goodsPropClass==1">
								<el-radio :label="item.select[0]">{{item.select[0]}}</el-radio>

							</el-radio-group>



							<el-select placeholder="请选择" v-model="AddCommodityParam.gpropsList2"
								v-if="item.goodsPropClass==2">
								<el-option v-for="item2 in item.select" :key="item2" :label="item2" :value="item2">
								</el-option>
							</el-select>



							<el-select v-model="AddCommodityParam.gpropsList3" multiple placeholder="请选择"
								v-if="item.goodsPropClass==3">
								<el-option v-for="item3 in item.select" :key="item3" :label="item3" :value="item3">
								</el-option>
							</el-select>

						</el-form-item>



					</el-form-item>


					</el-form-item>

					<el-form-item label="来源门店">
						<el-select v-model="AddCommodityParam.shopId" @change="loadWarehouseInfos"
							placeholder="请选择门店...">
							<el-option v-for="(item,index) in shopInfos" :label="item.shopName" :value="item.shopId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="仓库">
						<el-select v-model="AddCommodityParam.warehouseId">
							<el-option v-for="item in warehouseInfos" :label="item.warehouseName"
								:value="item.warehouseId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="官方价">
						<template>
							<el-input-number v-model="AddCommodityParam.goodsOfficePrice" :precision="2" :step="0.1"
								:max="100000"></el-input-number>
						</template>
					</el-form-item>
					<el-form-item label="收购价">
						<template>
							<el-input-number v-model="AddCommodityParam.goodsBuyPrice" :precision="2" :step="0.1"
								:max="100000"></el-input-number>
						</template>
					</el-form-item>
					<el-form-item label="商品描述">
						<el-input type="textarea" v-model="AddCommodityParam.goodsMessage" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="录入人">
						<el-input v-model="AddCommodityParam.userInput" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="录入时间">
						<el-date-picker v-model="AddCommodityParam.userInputtime" type="date" placeholder="选择录入时间"
							value-format="yyyy-MM-dd">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="是否可售">
						<el-radio-group v-model="AddCommodityParam.warehouseStatus">
							<el-radio :label="0">可售</el-radio>
							<el-radio :label="1">不可售</el-radio>
						</el-radio-group>
					</el-form-item>
					<!-- 					<el-form-item label="库存数量">
						<el-input v-model="AddCommodityParam.warehouseCount" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="创建人">
						<el-input v-model="AddCommodityParam.userCreator" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="创建时间">
						<el-date-picker v-model="AddCommodityParam.creatorTime" type="date" placeholder="选择创建时间"
							value-format="yyyy-MM-dd">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="评鉴状态">
						<el-radio-group v-model="AddCommodityParam.goodsProcess">
							<el-radio :label="0">初始状态</el-radio>
							<el-radio :label="1">待鉴定</el-radio>
							<el-radio :label="2">待评估</el-radio>
							<el-radio :label="3">信息失效</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="显示状态">
						<el-radio-group v-model="AddCommodityParam.warehouseDisplayStatus">
							<el-radio :label="0">显示</el-radio>
							<el-radio :label="1">隐藏</el-radio>
						</el-radio-group>
					</el-form-item> -->
				</el-form>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="clearAddForm">重 置</el-button>
				<el-button type="primary" @click="buSureAdd">确认添加</el-button>
			</div>
		</el-dialog>




		
		<el-dialog @close="clearAddvaForm" title="估价" :visible.sync="addMovieVisible">
			<div>
				<el-form>
					<el-button @click="openEvalution">查看历史记录</el-button>
					<el-form-item label="官方价">
						<el-input v-model="addevalutionParam.evaluationOfficialprice"></el-input>
					</el-form-item>
					<el-form-item label="典当价">
						<el-input v-model="addevalutionParam.evaluatioPawnprice"></el-input>
					</el-form-item>
					<el-form-item label="收购价">
						<el-input v-model="addevalutionParam.evaluationPurchasingprice"></el-input>
					</el-form-item>
					<el-form-item label="售卖价">
						<el-input v-model="addevalutionParam.evaluationSaleprice"></el-input>
					</el-form-item>
					<el-form-item label="评估价">
						<el-input v-model="addevalutionParam.evaluationPrice"></el-input>
					</el-form-item>
					<el-form-item label="租价">
						<el-input v-model="addevalutionParam.evaluationRentalprice"></el-input>
					</el-form-item>	
					<el-form-item label="备注">
						<el-input v-model="addevalutionParam.evaluationRemarks"></el-input>
					</el-form-item>
				</el-form>
			</div>
		
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="saveValution">提 交</el-button>
			</div>
		</el-dialog>
		
		<el-dialog  title="估价" :visible.sync="addevalutionVisible">
			<div>
				<el-table :data="evalutions" >
					<el-table-column type="selection" label="序号">
					</el-table-column>
					<el-table-column type="index" label="序号">
					</el-table-column>
					<el-table-column prop="evaluationOfficialprice" label="官方价">
					</el-table-column>
					<el-table-column prop="evaluationPrice" label="评估价">
					</el-table-column>
					<el-table-column prop="evaluationAssessor" label="评估人">
					</el-table-column>
					<el-table-column prop="evaluationTime" label="评估时间">
					</el-table-column>
					<el-table-column prop="evaluationRemarks" label="备注">
					</el-table-column>
				</el-table>
			</div>
		</el-dialog>
		
		<el-dialog title="商品详情" :visible.sync="GoodsInfoVisible" style="height: 700px; border: 1px solid #eee">
			<el-form label-width="100px">
				<el-form label-width="100px">
					<el-form-item label="商品名">
						<el-input v-model="CommodityInfo.goodsTableName" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="品牌">
						<el-select v-model="CommodityInfo.goodsBrandsId" placeholder="请选择" :disabled="true">
							<el-option v-for="item in brandInfos" :label="item.goodsBrandName"
								:value="item.goodsBrandId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="所属一类">
						<el-select v-model="CommodityInfo.goodsGeneralId" @change="getLoadSmallInfo"
							placeholder="请选择一级类..." :disabled="true">
							<el-option v-for="(item,index) in generalInfos" :label="item.goodsGeneralName"
								:value="item.goodsGeneralId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="所属二类">
						<el-select v-model="CommodityInfo.goodsSmallId" @change="getLoadSmallerInfo"
							placeholder="请选择二级类..." :disabled="true">
							<el-option v-for="(item,index) in smallInfos" :label="item.goodsSmallName"
								:value="item.goodsSmallId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label=" 所属三类">
						<el-select v-model="CommodityInfo.goodsSmallerId" placeholder="请选择三级类..."
							@change="SmallerChange" :disabled="true">
							<el-option v-for="item in smallerInfos" :label="item.goodsSmallerName"
								:value="item.goodsSmallerId"></el-option>
						</el-select>
					</el-form-item>
		
					<el-form-item label="属性组" v-model="CommodityInfo.goodsPropList">
		
						<el-input v-model="CommodityInfo.goodsPropList" placeholder="请输入内容" :disabled="true">
						</el-input>
		
					</el-form-item>
		
					<el-form-item label="来源门店">
						<el-select v-model="CommodityInfo.shopId" @change="getloadWarehouseInfos" placeholder="请选择门店..."
							:disabled="true">
							<el-option v-for="(item,index) in shopInfos" :label="item.shopName" :value="item.shopId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="仓库">
						<el-select v-model="CommodityInfo.warehouseId" :disabled="true">
							<el-option v-for="item in warehouseInfos" :label="item.warehouseName"
								:value="item.warehouseId">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="官方价">
						<template>
							<el-input-number v-model="CommodityInfo.goodsOfficePrice" :precision="2" :step="0.1"
								:max="100000"></el-input-number>
						</template>
					</el-form-item>
					<el-form-item label="收购价">
						<template>
							<el-input-number v-model="CommodityInfo.goodsBuyPrice" :precision="2" :step="0.1"
								:max="100000"></el-input-number>
						</template>
					</el-form-item>
					<el-form-item label="商品描述">
						<el-input type="textarea" v-model="CommodityInfo.goodsMessage" placeholder="请输入内容">
						</el-input>
					</el-form-item>
					<el-form-item label="录入人">
						<el-input v-model="CommodityInfo.userInput" placeholder="请输入内容" :disabled="true">
						</el-input>
					</el-form-item>
					<el-form-item label="录入时间">
						<el-date-picker v-model="CommodityInfo.userInputtime" type="date" placeholder="选择录入时间"
							value-format="yyyy-MM-dd">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="是否可售">
						<el-radio-group v-model="CommodityInfo.warehouseStatus">
							<el-radio :label="0">可售</el-radio>
							<el-radio :label="1">不可售</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="库存数量">
						<el-input v-model="CommodityInfo.warehouseCount" placeholder="请输入内容" :disabled="true">
						</el-input>
					</el-form-item>
					<el-form-item label="创建人">
						<el-input v-model="CommodityInfo.userCreator" placeholder="请输入内容" :disabled="true">
						</el-input>
					</el-form-item>
					<el-form-item label="创建时间">
						<el-date-picker v-model="CommodityInfo.creatorTime" type="date" placeholder="选择创建时间"
							value-format="yyyy-MM-dd">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="评鉴状态">
						<el-radio-group v-model="CommodityInfo.goodsProcess">
							<el-radio :label="0">初始状态</el-radio>
							<el-radio :label="1">待鉴定</el-radio>
							<el-radio :label="2">待评估</el-radio>
							<el-radio :label="3">信息失效</el-radio>
						</el-radio-group>
					</el-form-item>
					<!-- 					<el-form-item label="显示状态">
						<el-radio-group v-model="AddCommodityParam.warehouseDisplayStatus">
							<el-radio :label="0">显示</el-radio>
							<el-radio :label="1">隐藏</el-radio>
						</el-radio-group>
					</el-form-item> -->
				</el-form>
			</el-form>
			<!-- 			<div slot="footer" class="dialog-footer">
				<el-button @click="clearAddForm">重 置</el-button>
				<el-button type="primary" @click="buSureAdd">确认添加</el-button>
			</div> -->
		</el-dialog>
		

		<div id="">


			<div class="searchWord">

				<el-form :inline="true" class="demo-form-inline">

					<el-form-item label="状态">

						<el-select clearable placeholder="请选择" v-model="findParam.status" style="width: 100px;">
							<el-option label="全部" value="">
							</el-option>
							<el-option label="店员提交（待鉴定）" value="1">
							</el-option>
							<el-option label=" 鉴定完成（待评估）" value="2">
							</el-option>
							<el-option label="估价完成（已评估）" value="3">
							</el-option>
							<el-option label="失效" value="4">
							</el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="操作人">
						<el-input v-model="findParam.operator" style="width: 100px;" class='searchs'
							placeholder="请输入搜索内容">
						</el-input>
					</el-form-item>


					<el-form-item label="模糊条件">
						<el-input v-model="findParam.key" style="width: 200px;" class='searchs' placeholder="请输入搜索内容">
						</el-input>
					</el-form-item>


					<el-form-item label="录入时间">
						<div class="block">
							<!-- <span class="demonstration">默认</span> -->
							<el-date-picker v-model="findParam.startTime" type="datetime" placeholder="选择日期时间">
							</el-date-picker>
						</div>
					</el-form-item>

					<el-form-item label="">
						<div class="block">
							<!-- <span class="demonstration">默认</span> -->
							<el-date-picker v-model="findParam.endTime" type="datetime" placeholder="选择日期时间">
							</el-date-picker>
						</div>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" icon="el-icon-search" round @click="search()">查询</el-button>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" plain @click="oppenCommodityModel()">新增商品</el-button>
					</el-form-item>
					<!-- 删除按钮 -->
					<el-form-item>
						<el-button type="danger" icon="el-icon-delete" circle :disabled="this.deleIds.length === 0"
							@click="deletePropGrop"></el-button>
					</el-form-item>
				</el-form>

			</div>






			<el-table :data="Commoditys" style="width: 100%" border @selection-change="handleSelectionChange">
				<el-table-column type="selection" width="55">
				</el-table-column>
				<el-table-column prop="commodityTableId" label="编号" width="55">
				</el-table-column>
				<el-table-column prop="goodsTableName" label="商品名称" width="160">
				</el-table-column>
				<el-table-column prop="commodityTableName" label="分类" width="160">
				</el-table-column>
				<el-table-column prop="userInput" label="录入人" width="160">
				</el-table-column>
				<el-table-column prop="userAppraiser" label="鉴定人" width="160">
				</el-table-column>
				<el-table-column prop="historyName" label="评估人" width="160">
				</el-table-column>
				<el-table-column prop="userInputtime" label="录入时间" width="160">
				</el-table-column>

				<el-table-column sortable label="状态" width="180">
					<template slot-scope="scope">
						{{ scope.row.goodsPropgroupStatus == 1 ? '停用' : '启用' }}
					</template>
				</el-table-column>

				<el-table-column fixed="right" label="操作" width="300">
					<template slot-scope="scope">
						<el-button type="warning" plain @click="ConnodityInfo(scope)">商品详情</el-button>
						<!-- <el-button type="text" size="mini" plain @click="openUpdateModel(scope)">修改</el-button> -->
						<el-button type="text" size="mini" plain @click="jianDing(scope.row)">鉴定</el-button>
						<el-button type="text" size="mini" plain @click="pingGu(scope.row)">评估</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<div id="">
			<el-pagination :current-change="findParam.indexPage" background layout="sizes,prev, pager, next, jumper"
				:total="total" :page-sizes="size" :page-size="findParam.pageSize" @current-change="changePage"
				@size-change="changePageSize">
			</el-pagination>
		</div>

		<!-- 鉴定的弹窗 -->
		<el-dialog title="商品鉴定" width="50%" :visible.sync="jianDingView">
			<el-form ref="form" label-width="120px">
				<el-form-item label="鉴定记录/条：">
					<el-input disabled style="display: inline-block; width: 200px;" size="mini"
						v-model="AppraisalHistoryDto.appraisalCount">
					</el-input>
					<!-- 查看鉴定记录 来个弹窗-->
					<el-button type="text" @click="seeHistory">鉴定记录</el-button>
				</el-form-item>
				<el-form-item label="正品/赝品：">
					<el-input style="display: inline-block; width: 200px;" size="mini"
						v-model="AddAppraisalParam.appraisalGoodsResult"></el-input>
				</el-form-item>
				<el-form-item label="新旧程度">
					<el-select v-model="AddAppraisalParam.appraisalGoodsQuality" placeholder="请选择几成新...">
						<el-option label="全新" :value="10"></el-option>
						<el-option label="九成新" :value="9"></el-option>
						<el-option label="八成新" :value="8"></el-option>
						<el-option label="七成新" :value="7"></el-option>
						<el-option label="轻微使用痕迹" :value="6"></el-option>
						<el-option label="严重使用痕迹" :value="5"></el-option>
						<el-option label="不值钱了" :value="4"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="鉴定人：">
					<el-input style="display: inline-block; width: 200px;" size="mini"
						v-model="AddAppraisalParam.appraisalGoodsName"></el-input>
				</el-form-item>
				<el-form-item label="鉴定图：">
					<el-form-item v-for="(object, index) in appraisalArray" :key="object.key"
						:prop="'object.' + index + '.value'">
						<el-input v-model="object.ImgTag" disabled style="width: 150px"></el-input>
						<el-input v-model="object.selectValue == 0 ? '必选':'可选'0" disabled style="width: 150px"></el-input>
						<el-upload class="upload-demo" action="http://localhost:8080/file/upload" list-type="picture"
							:on-success="loadSuccess" :beforeUpload="beforeLoad">
							<el-button size="mini" type="primary">点击上传</el-button>
							<div slot="tip" class="el-upload__tip">图标尺寸为36*36比例，大小不能超过2MB，图片只能为JPG、PNG、GIF格式</div>
						</el-upload>
					</el-form-item>
				</el-form-item>
				<el-form-item label="备注：">
					<el-input style="display: inline-block; width: 200px;" size="mini"
						v-model="AddAppraisalParam.appraisalGoodsMessage"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="beSureAddAppraiSal">完成鉴定</el-button>
				<el-button type="info" @click="jiandingChongzhi">重 置</el-button>
				<el-button type="danger" @click="quxiao">取 消</el-button>
			</span>
		</el-dialog>
		
		<!-- 查看鉴定记录弹窗 -->
				<el-dialog title="商品鉴定记录" width="50%" :visible.sync="historyvisible">
					<el-table style="width: 100%; " :data="appraisalHistoryList">
						<!-- 展示鉴定记录信息 -->
						<el-table-column prop="commodityTableId" label="商品编号"></el-table-column>
						<el-table-column prop="appraisalGoodsName" label="鉴定人"></el-table-column>
						<el-table-column prop="appraisalGoodsResult" label="鉴定结果"></el-table-column>
						<el-table-column prop="appraisalGoodsQuality" label="鉴定品质"></el-table-column>
						<el-table-column prop="appraisalGoodsTime" label="鉴定时间"></el-table-column>
						<el-table-column prop="appraisalGoodsMessage" label="备注"></el-table-column>
		<!-- 				<el-table style="width: 100%; " v-model ="historyappraisalArray">
							<el-table-column :prop="historyappraisalArray.ImgTag" label="鉴定图类型"></el-table-column>
							<el-table-column label="鉴定图">
								<template>
									<img :src="historyappraisalArray.imgUrl" width="60" height="60"></img>
								</template>
							</el-table-column>
						</el-table> -->
					</el-table>
				</el-dialog>
		
	
	
	</div>
</template>

<script>
	export default {
		data() {
			return {
				addevalutionVisible:false,
				AddGoodsVisible: false, //新增商品信息的弹窗默认关闭
				//添加商品信息的参数
				AddCommodityParam: {
					commodityTableId: null, //商品id
					goodsBrandsId: null, //品牌id
					goodsGeneralId: null, //大类id
					goodsSmallId: null, //二类id
					goodsSmallerId: null, //三类id
					goodsTableName: null, //商品名
					shopId: null, //门店id
					warehouseId: null, //仓库id
					goodsOfficePrice: null, //官方价
					goodsBuyPrice: null, //收购价
					goodsMessage: null, //商品描述
					userInput: null, //录入人
					userInputtime: null, //录入时间
					warehouseStatus: null, //是否可售
					warehouseCount: null, //库存数量
					warehouseDisplayStatus: null, //显示状态
					userCreator: null, //创建人
					creatorTime: null, //创建时间
					goodsProcess: null, // 评鉴状态 1 店员提交（待鉴定） 2 鉴定完成（待评估）  3 估价完成（已评估）4失效
					gpropsList1: [],
					gpropsList2: [],
					gpropsList3: [],
				
				},
				//接收大类信息
				generalInfos: [],
				//接收二类信息
				smallInfos: [],
				//接收三类信息
				smallerInfos: [],
				//接收品牌信息
				brandInfos: [],
				//接收门店信息
				shopInfos: [],
				//根据门店查到的仓库信息 一个门店对应多个仓库
				warehouseInfos: [],
				//接收选中的商品信息id
				deleIds: [],
				//鉴定弹窗
				jianDingView: false,
				//鉴定所需参数
				AddAppraisalParam: {
					appraisalGoodsResult: null,
					appraisalGoodsQuality: null,
					appraisalGoodsName: null,
					appraisalGoodsMessage: null,
					commodityTableId: null,
					appraisalGoodsPicture: null
				},
				//接收鉴定图的数据（后端传来的时json格式，前端要转换）
				AppraisalHistoryDto: {
					appraisalPicture: null,
					appraisalCount: null //鉴定记录条数
				},
				//接收鉴定图对象的数组
				appraisalArray: [{
					ImgTag: null, //正面、背面还是标签图
					selectValue: null, //必选：0，可选：1
					imgUrl: null
				}],
				//接收自定义图鉴的数据：json格式
				diyImg: [{
					ImgTag: null, //正面、背面还是标签图
					selectValue: null, //必选：0，可选：1
					imgUrl: null
				}],
				goodsId: null,
				//接收鉴定记录的数组
				appraisalHistoryList: [],
				historyvisible: false,
				
				addevalutionParam:{
					goodsId:null,
					evaluationOfficialprice:null,
					evaluatioPawnprice:null,
					evaluationPurchasingprice:null,
					evaluationSaleprice:null,
					evaluationPrice:null,
					evaluationRentalprice:null,
					evaluationRemarks:null
				},
				addMovieVisible:false,

				
				isAddVisible: false,
				saveCommodityInfo: {
					shopId: null,
					goodsTableName: null,
					userGomoney: null,
					goodsMessage: null,
					goodsPropgroupName: null,
					goodsPropgroupStatus: null,
					goodsSmallIds: [],
				},
				Shops: [],
				//分页查询条件s
				findParam: {
					endTime: null,
					startTime: null,
					key: null,
					status: null,
					operator: null,
					indexPage: 1, //当前页码
					pageSize: 5, //当前页码能看几条
					// 给他一个默认值可以修改
				},
				Commoditys: [],
				total: 0,
				size: [3, 5, 10, 20, 30],
				addModel: false,
				checks: [],
				menusRoles: [],
				addrolesMenus: {
					roleId: null,
					checkIds: []
				},
				updatePropGroupInfo: [], //接收修改商品的参数
				listGoodsSmall: [],
				evalutions:[],
				
			
				listGoodProp: [], //属性组,
				CommodityInfo: [], //查询回来的当前属性
				GoodsInfoVisible: false
			}

		},
		methods: {
			//取消
			quxiao() {
				this.jianDingView = false;
				this.AddAppraisalParam.appraisalGoodsPicture = null;
				this.AppraisalHistoryDto.appraisalPicture = null;
			},
			
			SmallerChange() {
				//三类查询以后生成属性组
				this.AddCommodityParam.gpropsList1 = [];
				this.AddCommodityParam.gpropsList2 = [];
				this.AddCommodityParam.gpropsList3 = [];
				this.$http.post("/commodity-table/listGoodsProps.do/" + this.AddCommodityParam.goodsSmallerId).then(
					resp => {
						if (resp.data.code == 200) {
							if (resp.data.data) {
			
							}
							if (resp.data.data.length <= 0) {
								this.$message({
									message: '请先给二类商品生成属性组',
									type: 'warning'
								});
							} else {
			
								// this.AddCommodityParam.GpropsList = new Array(10);
								// console.log(this.AddCommodityParam.GpropsList)
								this.listGoodProp = resp.data.data;
			
								// console.log(this.listGoodProp)
							}
			
						} else {
							this.$message({
								message: '查询属性组失败',
								type: 'warning'
							});
						}
					})
			},
			//查询详情的2类
			getLoadSmallInfo() {
				var generalId = this.CommodityInfo.goodsGeneralId;
				this.$http.get("/goods-small/listSmallByGeneralId/" + generalId).then(resp => {
					if (resp.data.code == 200) {
						this.smallInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询二类失败',
							type: 'warning'
						});
					}
				})
			},
			getLoadSmallerInfo() {
				var smallId = this.CommodityInfo.goodsSmallId;
				this.$http.get("/goods-smaller/listSmallerBySmallId/" + smallId).then(resp => {
					if (resp.data.code == 200) {
						this.smallerInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询三类失败',
							type: 'warning'
						});
					}
				})
			},
			//根据门店信息 查询仓库
			getloadWarehouseInfos() {
				var shopId = this.CommodityInfo.shopId;
				this.$http.get("/warehouse-shop/listWareHouseByShopId/" + shopId).then(resp => {
					if (resp.data.code == 200) {
						this.warehouseInfos = resp.data.data;
			
					} else {
						this.$message({
							message: '查询仓库失败',
							type: 'warning'
						});
					}
				})
			},
			//删除商品
			deleteGoods() {
				this.$http.post('/commodity-table/removeGoodsCommodityByIds.do', this.deleIds)
					.then(resp => {
						if (resp.data.code == 200) {
			
							this.$message({
								type: 'success',
								message: '删除成功 '
							});
							this.ListCommodityDto();
							//初始化勾选
							// this.deleIds = [];
						} else {
							this.$message({
								type: 'error',
								message: '删除失败 ' + resp.data.msg
							});
						}
			
					})
			},
			//获取商品详情
			ConnodityInfo(scope) {
				//商品详情
				this.$http.post('/commodity-table/getCommodityInfo/' + scope.row.commodityTableId)
					.then(resp => {
						if (resp.data.code == 200) {
							console.log(resp.data.data)
							this.CommodityInfo = resp.data.data;
							this.GoodsInfoVisible = true;
							this.loadBrandInfos();
							this.getloadWarehouseInfos();
							this.getLoadSmallInfo();
							this.getLoadSmallerInfo();
							this.loadShopInfo();
			
							this.CommodityInfo.shopId = parseInt(resp.data.data.shopId);
							this.CommodityInfo.goodsBrandsId = parseInt(resp.data.data.goodsBrandsId);
						} else {
			
						}
			
					})
			
			
			
			},
			
			//加载大类信息
			loadGeneralInfo() {
				this.$http.get("/goods-general/listAllGeneral").then(resp => {
					if (resp.data.code == 200) {
						this.generalInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询大类失败',
							type: 'warning'
						});
					}
				})
			},
			//根据选中的大类id加载二级类信息
			loadSmallInfo() {
				var generalId = this.AddCommodityParam.goodsGeneralId;
				this.$http.get("/goods-small/listSmallByGeneralId/" + generalId).then(resp => {
					if (resp.data.code == 200) {
						this.smallInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询二类失败',
							type: 'warning'
						});
					}
				})
			},
			//根据选中的二类id加载三级类信息
			loadSmallerInfo() {
				var smallId = this.AddCommodityParam.goodsSmallId;
				this.$http.get("/goods-smaller/listSmallerBySmallId/" + smallId).then(resp => {
					if (resp.data.code == 200) {
						this.smallerInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询三类失败',
							type: 'warning'
						});
					}
				})
			},
			//加载品牌信息
			loadBrandInfos() {
				this.$http.get("/goods-brand/listAllBrand").then(resp => {
					if (resp.data.code == 200) {
						this.brandInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询品牌失败',
							type: 'warning'
						});
					}
				})
			},
			//加载门店信息
			loadShopInfo() {
				this.$http.get("/shop-table/getAllShop").then(resp => {
					if (resp.data.code == 200) {
						this.shopInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询门店失败',
							type: 'warning'
						});
					}
				})
			},
			//根据门店信息 查询仓库
			loadWarehouseInfos() {
				var shopId = this.AddCommodityParam.shopId;
				this.$http.get("/warehouse-shop/listWareHouseByShopId/" + shopId).then(resp => {
					if (resp.data.code == 200) {
						this.warehouseInfos = resp.data.data;
					} else {
						this.$message({
							message: '查询仓库失败',
							type: 'warning'
						});
					}
				})
			},
			//添加商品信息弹窗的重置按钮
			clearAddForm() {
				this.AddCommodityParam = {
					commodityTableId: null,
					goodsBrandsId: null,
					goodsGeneralId: null,
					goodsSmallId: null,
					goodsSmallerId: null,
					goodsTableName: null,
					shopId: null,
					warehouseId: null,
					goodsOfficePrice: null,
					goodsBuyPrice: null,
					goodsMessage: null,
					userInput: null,
					userInputtime: null,
					warehouseStatus: null,
					warehouseCount: null,
					warehouseDisplayStatus: null,
					userCreator: null,
					creatorTime: null,
					goodsProcess: null
				}
			},
			//打开新增商品弹窗
			oppenCommodityModel() {
				this.clearAddForm();
				this.AddGoodsVisible = true;
			},
			//确认添加按钮
			buSureAdd() {
				this.$http.post("/commodity-table/addCommodityInfo", this.AddCommodityParam).then(resp => {
					if (resp.data.code == 200) {
						this.$message({
							message: '添加成功',
							type: 'success',
						});
					} else {
						this.$message({
							message: '添加失败' + resp.data.msg,
							type: 'warning'
						});
					}
				})
				this.AddGoodsVisible = false;
			},
			clearAddvaForm(){
			this.addevalutionParam={
					goodsId:null,
					evaluationOfficialprice:null,
					evaluatioPawnprice:null,
					evaluationPurchasingprice:null,
					evaluationSaleprice:null,
					evaluationPrice:null,
					evaluationRentalprice:null,
					evaluationRemarks:null
				}
			},
			pingGu(row) {
				this.clearAddvaForm();
				this.addevalutionParam.goodsId = row.goodsSmallId;
				this.addMovieVisible=true;
				
				// console.log(this.addevalutionParam.goodsId)
				// console.log(row.goodsSmallId)
			},
			saveValution(){
				this.$http.post("/evalution/SaveEvalution", this.addevalutionParam).then(resp => {
					if (resp.data.code == 200) {
						this.addMovieVisible = !this.addMovieVisible;
						this.$message({
							message: '添加成功',
							type: 'success',
				
						});
						this.ListCommodityDto();
						this.clearAddvaForm();
					
					} else {
						this.$message({
							type: 'error',
							message: '添加失败 ' + resp.data.msg
						});
					}
				})
			},
			openEvalution(){
				this.addevalutionVisible=true;
				this.$http.get("/evalution/getEvalution/"+this.addevalutionParam.goodsId).then(resp => {
					if (resp.data.code == 200) {
						this.evalutions=resp.data.data;
					} else {
						this.$message({
							type: 'error',
							message: '查询失败 ' + resp.data.msg
						});
					}
				
				})
			},
			
			
			
			
			
			
			
			//重置按钮
			jiandingChongzhi() {
				this.AddAppraisalParam.appraisalGoodsResult = null,
					this.AddAppraisalParam.appraisalGoodsQuality = null,
					this.AddAppraisalParam.appraisalGoodsName = null,
					this.AddAppraisalParam.appraisalGoodsMessage = null
			},
			jianDing(row) {
				this.appraisalArray = null;
				this.jianDingView = true;
				this.AddAppraisalParam.appraisalGoodsPicture = null;
				this.AddAppraisalParam.commodityTableId = row.commodityTableId;
				this.goodsId = row.commodityTableId;
				this.AddAppraisalParam.goodsSmallId = row.goodsSmallId;
				//点击鉴定  从后端获取鉴定图的数据（是json字符串格式）
				this.$http.get("/appraisal-goods/appraisalPictureInfo/" + this.AddAppraisalParam.goodsSmallId)
					.then(resp => {
						if (resp.data.code == 200) {
							// console.log(resp.data.data)
							this.AppraisalHistoryDto.appraisalPicture = resp.data.data.appraisalGoodsPicture;
							this.AppraisalHistoryDto.appraisalCount = resp.data.data.appraisalCount;
							if (this.AppraisalHistoryDto.appraisalPicture == null) {
								this.$message({
									type: 'error',
									message: '该商品没有鉴定图'
								});
							} else {
								this.appraisalArray = JSON.parse(this.AppraisalHistoryDto
									.appraisalPicture); //将鉴定图转化为对象数组
							}
						} else {
							this.$message({
								type: 'error',
								message: '鉴定图查询失败'
							});
						}
					})
			},
			// 查看鉴定记录
			
			seeHistory() {
				this.historyvisible = true;
				this.$http.get("/appraisal-goods/appraisalHistoryInfo/" + this.goodsId)
					.then(resp => {
						if (resp.data.code == 200) {
							this.appraisalHistoryList = resp.data.data;
							// this.historyappraisalArray = JSON.parse(this.appraisalHistoryList[0].appraisalGoodsPicture);
							// console.log(this.historyappraisalArray);
							this.$message({
								type: 'success',
								message: resp.data.msg
							});
						} else {
							this.$message({
								type: 'error',
								message: resp.data.msg
							});
						}
					})
			},
			
			//上传图标后的回调函数
			loadSuccess(response) {
				for (var i = 0; i < this.appraisalArray.length; i++) {
					this.appraisalArray[i].imgUrl = response.data;
				}
			},
			
			
			//完成鉴定
			beSureAddAppraiSal() {
				var json = null;
				for (var i = 0; i < this.appraisalArray.length; i++) {
					json = JSON.stringify(this.appraisalArray[i]);
				}
				this.AddAppraisalParam.appraisalGoodsPicture = json;
				this.$http.post("/appraisal-goods/addAppraisalBycommodityId", this.AddAppraisalParam)
					.then(resp => {
						if (resp.data.code == 200) {
							this.ListCommodityDto();
							this.jiandingChongzhi();
							this.jianDingView = false;
							this.$message({
								type: 'success',
								message: '鉴定成功 '
							});
						} else {
							this.$message({
								type: 'error',
								message: '鉴定失败 '
							});
						}
					})
			},
			
			
			//鉴定图的规范
			beforeLoad(file) {
				var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
				const extension = testmsg === 'jpg'
				const extension2 = testmsg === 'png'
				const extension3 = testmsg === 'gif'
				const Imgsize = file.size / 1024 / 1024 < 2
				if (!extension && !extension2 && !extension3) {
					this.$message({
						message: '上传图片仅支持 jpg，png，gif格式!',
						type: 'warning'
					});
				}
				if (!Imgsize) {
					this.$message({
						message: '上传图片大小不能超过 2MB!',
						type: 'warning'
					});
				}
				return extension || extension2 || extension3 && Imgsize;
			},
			listShops() {
				this.$http.post('/commodity-table/listShops.do')
					.then(resp => {
						if (resp.data.code == 200) {
							this.Shops = resp.data.data;
						} else {
							this.$message({
								type: 'error',
								message: '获取店铺失败 '
							});
						}

					})
			},
			listGoodsSmallAxios() {
				this.$http.post('/goods-propgroup/listGoodsSmall.do')
					.then(resp => {
						if (resp.data.code == 200) {

							for (var i = 0; i < resp.data.data.length; i++) {

								this.listGoodsSmall.push({
									key: resp.data.data[i].goodsSmallId,
									label: resp.data.data[i].goodsSmallName
								})
							}


						} else {
							this.$message({
								type: 'error',
								message: '获取小类失败 '
							});
						}

					})
			},
			handleSelectionChange(val) {
				//获取勾选的内容

				//初始化
				this.deleIds = [];
				for (let i = 0; i < val.length; i++) {
					this.deleIds.push(val[i].goodsPropgroupId);
				}
			},
			deletePropGrop() {
				this.$http.post('/goods-propgroup/removePropGroupByIds.do', this.deleIds)
					.then(resp => {
						if (resp.data.code == 200) {

							this.$message({
								type: 'success',
								message: '删除成功 '
							});
							this.ListCommodityDto();
							//初始化勾选
							// this.deleIds = [];
						} else {
							this.$message({
								type: 'error',
								message: '删除失败 ' + resp.data.msg
							});
						}

					})
			},
			search() {
				this.ListCommodityDto();
			},
			//加载所有商品
			ListCommodityDto() {
				this.$http.post("/commodity-table/listCommodity.do", this.findParam)
					.then(resp => {
						if (resp.data.code == 200) {
							this.deleIds = [];
							this.Commoditys = resp.data.data.list;
							this.total = resp.data.data.total;
							this.findParam.indexPage = resp.data.data.indexPage;

						}

					})
			},
			changePage(page) {
				this.findParam.indexPage = page;
				this.ListCommodityDto();
			},
			changePageSize(size) {
				this.findParam.pageSize = size;
				this.ListCommodityDto();
			},


		},
		created() {
			this.ListCommodityDto();
			this.loadGeneralInfo();
			this.loadShopInfo();
			this.loadBrandInfos();
		}
	}
</script>

<style scoped>

</style>
